import {request} from '../../network/index'

Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		active: 0,
		activeKey: 0,
		toplist:[],
		singer:[],
    option2: [
      { text: '华语', value: 1 },
      { text: '欧美', value: 2 },
      { text: '韩国', value: 3 },
      { text: '日本', value: 4 },
    ],
    value2: 1,
	},
	async change(value){
		console.log(value.detail);
		let singer = await request('/toplist/artist',{type:value.detail})
		console.log(singer);
		this.setData({
			singer:singer.data.list.artists
		})
	},
	async topList(event){
		let id = event.currentTarget.dataset.id
		wx.navigateTo({
			url: `/pages/musciListDetial/musciListDetial?id=${id}&is=true`
		})
	},
	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad:async function (options) {
		let	topList = await request('/toplist') 
		let arr1 = topList.data.list.slice(0,12)
		let arr2 = topList.data.list.slice(23)
		this.setData({
			toplist:[...arr1,...arr2]
		})
	},
	async onChange(event){
		let name = event.detail.name
		if(name === 1){
			let singer = await request('/toplist/artist')
			console.log(singer);
			this.setData({
				singer:singer.data.list.artists
			})
		}
	},
	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function () {

	},

	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow: function () {

	},

	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide: function () {

	},

	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload: function () {

	},

	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh: function () {

	},

	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom: function () {

	},

	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage: function () {

	}
})